<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>updateDateByDay</title>
</head>

<body>
    <script>
        const updateDateByDay = (date, n) => {
            date = new Date(date);
            date.setDate(date.getDate() + n);
            return date.toISOString().split('T')[0];
        };
        document.write(`当前日期往前10天是: ${updateDateByDay(new Date(), -10)},往后10天是: ${updateDateByDay(new Date(), 10)}`)
    </script>
</body>

</html>